﻿#include "mysqllink.h"
#include "systemfile.h"

mySqlLink::mySqlLink(datebase *db,QObject *parent) :
    QThread(parent)
{
}

void mySqlLink::run()
{  
    qDebug()<<"mySqlLink::run()";
    datebase::GetInstance()->mySql_db.setHostName(systemFile::GetInstance()->serverIp);
    datebase::GetInstance()->mySql_db.setDatabaseName(systemFile::GetInstance()->databaseName);
    datebase::GetInstance()->mySql_db.setUserName(systemFile::GetInstance()->userName);
    datebase::GetInstance()->mySql_db.setPassword(systemFile::GetInstance()->passWord);
    datebase::GetInstance()->mySql_db.setPort(systemFile::GetInstance()->serverPort);
    qDebug()<<"ip="
            <<systemFile::GetInstance()->serverIp
            <<"databaseName="
            <<systemFile::GetInstance()->databaseName
            <<"userName="
            <<systemFile::GetInstance()->userName
            <<"passwd="
            <<systemFile::GetInstance()->passWord;
    if(datebase::GetInstance()->mySql_db.open())
    {
        qDebug()<<"open mysql database success";
    }else{
        qDebug()<<"Unable to open mysql database"
                <<systemFile::GetInstance()->serverIp
                <<systemFile::GetInstance()->databaseName
                <<systemFile::GetInstance()->userName
                <<systemFile::GetInstance()->passWord
                <<systemFile::GetInstance()->serverPort;
    }
    this->quit();
}
